﻿package anshe.test
{
	import anshe.widget.AnsheServer;
	
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import org.dstart.object.memo.MemoObject;

	public class AnsheServerTest extends AnsheServer
	{
		public var sprBg:Sprite;
		public var btnGame1:SimpleButton;
		public var btnGame2:SimpleButton;
		public var btnGame3:SimpleButton;
		
		public function AnsheServerTest()
		{
			MemoObject.create(this.btnGame1, "俄罗斯方块(Tetris)");
			MemoObject.create(this.btnGame2, "聊天程序(AnsheChat)");
			
			sprBg.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
			sprBg.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
						
			this.btnGame1.addEventListener(MouseEvent.CLICK, onLoadSWF);
			this.btnGame2.addEventListener(MouseEvent.CLICK, onLoadSWF);
			this.btnGame3.addEventListener(MouseEvent.CLICK, onLoadSWF);
		}
		
		//	开始拖动对象窗口
		private function onStartDrag(e:MouseEvent):void
		{
			this.startDrag();
			this.stage.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
		}
		
		//	停止拖动对象窗口
		private function onStopDrag(e:MouseEvent):void
		{
			this.stopDrag();
			this.stage.removeEventListener(MouseEvent.MOUSE_UP, onStopDrag);
		}
		
		private function onLoadSWF(e:MouseEvent):void
		{
			// trace("doInHere", this.space);
			
			//**
			if(this.space)
			{
				switch(e.target)
				{
					case this.btnGame1 :
						Talk("I'm load default");
						LoadFiles("Tetris");
						break;
					
					case this.btnGame2 :
						Talk("I'm load russianbox");
						LoadFiles("AnsheChat");
						break;
					
					case this.btnGame3 :
						Talk("I'm load MMY");
						// LoadFiles("毛毛羊.swf");
						break;
				}
			}
			else
			{
				ShowMessage("Can't find space Object");
			} //**/
		}
	}
}